/**
 * 控制台查看新增材料商品
 * 胡琼
 * 2017/8/21
 **/
var testConfig = require('../testConfig');
const ipcRenderer = require('electron').ipcRenderer;
var l = parseInt(window.sessionStorage.getItem("runTimes"));
var planData = JSON.parse(window.sessionStorage.getItem('planData'));
var caseData =  planData.cases[l];
var msg = {
    reportId:planData.reportId,
    taskId:planData.taskId,
    caseId:caseData.caseId,
    caseNumber:caseData.caseNumber,
    isOver:'false'
};
function TestProject() {
    this.init = function () {
        var arr = [];
        arr.push(this.step1,
            this.step2,
            this.step3);
        testConfig.testFun.runStep(arr);
    };
    this.step1 = function () {
        $("#aside-nav").find("div.coords").eq(5).find("a")[0].click();
        testConfig.testFun.ai().find("#goodsName").val("自动化测试商品2");
        msg.stepResult = {
            byname:"consoleInputName",
            realData:testConfig.testFun.ai().find("#goodsName").val()
        };
        ipcRenderer.sendToHost(JSON.stringify(msg));
    };
    this.step2 = function () {
        testConfig.testFun.ai().find("#query")[0].click();
        msg.stepResult = {
            byname:"consoleShowData",
            realData:testConfig.testFun.ai().find(".goodsNameClasses").val()
        };
        ipcRenderer.sendToHost(JSON.stringify(msg));
    };
    this.step3 = function(){
        var address = window.location.href;
        var r = parseInt(window.sessionStorage.getItem("runTimes"));
        if(planData.cases[r+1].caseNumber){
            if (address.indexOf("?") > 0) {
                window.location.href = address + "&_from=" + planData.cases[r+1].caseNumber;
            } else {
                window.location.href = address + "?_from=" + planData.cases[r+1].caseNumber;
            }
        }
        window.sessionStorage.setItem("runTimes",r+1);
    }
}
function testStart() {
    var test = new TestProject();
    test.init();
}
exports.start = testStart;



